{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\lang1033\f0\fs20 TI-86 EDITOR DOCUMENTATION\par
===========================\par
To make an editor, you need to know about a few routines:\par
\par
1. _set_context($40ed)--Sets the state monitor to use new context vectors to control keypresses. \par
Misuse of this routine will cause a crash!\par
 Input: hl->vector table. (use .dw vector address)\par
 Output: Vectors set.\par
\par
2. _setTitle($4fa8)--Displays title of editor.\par
 Input: hl->zero terminated title string.\par
 Output: Title Displayed.\par
\par
3. _adispnumvars($5738)--Displays editor. Before calling this, make sure the editor vars exist!\par
 Input: _numedTbl ($d069) = start of editor table.\par
 Output: Editor Displayed.\par
\par
4. _aseteditcurrent($5741)--Sets the editor cursor at row stored in _curRow.\par
 Input: Call _adispnumvars first, then _curRow = row to start editing.\par
 Output: Edit cursor set at row in _curRow.\par
\par
5. _amode_exec($5760 and $4a0a, a.k.a. _set_mode)--Switches selector menu, no inputs\par
 Input: None.\par
 Output: Item under select cursor is highlited and bit is flipped.\par
\par
6. _RecalledOp1($4fb8)--Recalls value of _OP1 into the editor at cursor location. This routine is used to display the answer following a calculation.\par
 Input: _OP1=result of calculation, _curRow=row to display at\par
 Output: Value is displayed at cursor location.\par
\par
7. _setIndicator($500f)--Sets small square on left edge after solving for a variable.\par
 Input: a=row to set at, c=char to display. (usually $d0)\par
 Output: Character is set at row. _curCol is set to zero.\par
\par
8. _clearbal_asap($56bb)--Used to clear the indicators. Useful when solving for multiple variables.\par
 Input: de->row,col to begin clearing at. (If equal to 1, then all indicators in editor will be cleared.), set 6,(iy+$00)\par
 Output: Indicators cleared, starting at row,col.\par
\par
**Calculations use OP Math. See "ti86.ops.inc" for routines and documentation. When calculating, the contents of the editor vars are stored in them.**\par
\par
**Set _winTop to $01 and _winBtm to $07 if using a title.**\par
\par
TABLE FORMAT (for editor routines):\par
-------------------------------------\par
For a variable, use the following:\par
.db $ff,$ff,$ff (only if at the start of the table.)\par
.db \i Position, Vartype  \i0 (position of var in editor, type of var)\par
.dw \i zero terminated text string\i0  (for variable)\par
.db \i name of variable\i0  (in variable name format)\par
\par
For a Mode Selector Menu (the kind that blinks),use the following:\par
.db $ff,$ff,$ff (only if at the start of the table.)\par
.db 0,$15\par
.dw \i pointer to mode data\i0\par
.db 0\par
\par
**At the beginning and ends of the table, use ".db $ff,$ff,$ff" to seperate editors from each other.**\par
\par
MODE DATA (for selector menus):\par
-------------------------------\par
.dw \i menutitle\i0  (zero terminated title str for menu. Use ".dw 0" if you don't want a title.)\par
.db \i ModeCount\i0  (the number of selector items)\par
.db 1,0,$fe,0 (these for bytes usually stay the same.)\par
.db \i row,col\i0  (where to print menu items.)\par
.db \i length byte of menu string\i0  (so it knows how many bytes to highlight.)\par
.dw \i zero terminated menu string\i0  (self explanatory.)\par
.dw \i Flag\i0  (specifies which byte to modify. You can use an offset of _Flags to modify the "iy flags".)\par
 call \i routine\i0  (the address of the function called when the user selects this item.)\par
 ret\par
.db \i byte,byte\i0  (specifies which bit to flip when item is selected. If the first byte is 0, then the string will be highlited. If not equal to 0, it will be normal. The second byte specifies which bit to flip)\par
.db $ff,$ff,$ff (only if this is the end of the editor table.)\par
\par
**For each menu item, the above format should be followed.**\par
\par
VECTOR TABLE (for _set_context routine):\par
----------------------------------------\par
.dw _anumhandlekey ($5744--handles the keypresses), or a user-defined key handler. (see below)\par
.dw _numPPutAway ($502c)\par
.dw _anumputaway ($574a)\par
.dw _aredispfield ($5747)\par
.dw _NumError ($5043)\par
.dw _anumsizewind ($574d)\par
.db $0a (rom page to use for routines.)\par
\par
**Consult Jimi Malcolm's guide (http://guide.ticalc.org) for information on creating and executing menus.**\par
\par
  Since it was previously unknown, I will elaborate on the use of the type $03 menu used to execute an assembly program.\par
This is used in conjunction with the _set_context routine, and requires a user-defined key handler. The $03 is followed by a byte that key handler checks for (see below) to jump to called routine.\par
Example:\par
 ld hl,vectors\par
 call _set_context\par
 ld hl,menu\par
 call _ASAPloadmenu   ;($49c8)\par
 jp _funcDisp    ;($49e8)\par
\par
menu:\par
.db $01,$05\par
.dw 0,0,0,0          ;(for the first four slots to be blank)\par
.dw fifth_slot\par
fifth_slot:\par
.db $03,$fd,$01,"ITEM",0   ;displays "ITEM" in fifth slot\par
\par
vectors:\par
.dw key_handler\par
.dw _numPPutAway\par
.dw _anumputaway\par
.dw _aredispfield\par
.dw _NumError\par
.dw _anumsizewind\par
.db $0a\par
\par
key_handler:\par
 cp $fd                  ;a=keycode\par
 jp nz,_anumhandlekey    ;if not $fd, use default key handler\par
 ld a,(_keyextend)       ;$c007--holds next byte (extended key)\par
 cp $01                  ;if equal to $01 (as in example), then execute routine\par
 jp z,routine            \par
 jp _anumhandlekey       ;it wasn't equal to $01--execute default key handler\par
\par
routine:\par
 jp _clrLCD              ;clear screen and return\par
\par
   Type $01 is also used to execute a routine. It is possible to call ROM without crashing if you set the rom page to $0d. To do this use the following:\par
\par
routine:\par
 ld a,$0d     ;rom page\par
 out (5),a    ;send value out of rom port (loads page)\par
 call _clrLCD ;the rest of the routine goes here (just an example)\par
 ret          ;return from call\par
\par
--(C) 2008, Scubadude. \par
\par
\par
}
 